const seq = require("../db/seq");
const Goods = require("./goods.model");
const { DataTypes } = require("sequelize");

const Cart = seq.define("sbdz_cart", {
  goods_id: {
    type: DataTypes.INTEGER,
    allowNull: false,
    comment: "商品id",
  },
  user_id: {
    type: DataTypes.INTEGER,
    allowNull: false,
    comment: "用户id",
  },
  number: {
    type: DataTypes.INTEGER,
    allowNull: false,
    defaultValue: 1,
    comment: "商品数量",
  },
  // selected: {
  //   type: DataTypes.BOOLEAN,
  //   unique:false,
  //   defaultValue: true,
  //   comment: "是否选中",

  // },
});
Cart.sync({});
Cart.belongsTo(Goods, {
  foreignKey: "goods_id",
  as:'goods_info'
}); //关联表
module.exports = Cart;
